package HLCustomUI;

import HLLib.base.HLGraphics;
import HLLib.base.HLGraphics_H;
import HLLib.base.HLImage;
import HLLib.base.HLInputManager_H;
import HLLib.base.HLString;
import HLLib.control.HLControl_H;

public class HLListBoxItemIconText extends HLIListItem implements HLControl_H, HLInputManager_H, HLGraphics_H {
    public HLString name;

    public HLImage icon;

    public HLImage iconBack;

    public void Init(HLString name, HLImage iconBack, HLImage icon) {
        this.name = name;
        this.icon = icon;
        this.iconBack = iconBack;
    }

    public int GetItemHeight() {
        int tmpHeight = iconBack.GetHeight();
        tmpHeight += 2;
        return tmpHeight;
    }

    public void Render(HLGraphics g, int rectX, int rectY, int rectWidth, int rectHeight, boolean selected) {
        int tmpX = rectX;
        tmpX += 4;
        int tmpY = rectY;
        tmpY += 1;

        int tmpWidth = rectWidth;
        tmpWidth -= 8;

        int tmpHeight = rectHeight;
        tmpHeight -= 2;
        g.FillRectAlpha(tmpX, tmpY, tmpWidth, tmpHeight, 0x330093d2);
        int startX = rectX;
        startX += 8;
        g.DrawImageAdjustable(iconBack, startX, rectY, rectWidth, rectHeight, TRANS_NONE, LEFT_VCENTER);
        int iconBackWidth = iconBack.GetWidth();
        g.DrawImageAdjustable(icon, startX, rectY, iconBackWidth, rectHeight, TRANS_NONE, HCENTER_VCENTER);
        startX += iconBackWidth;
        startX += 4;

        g.DrawStringAdjustable(name, 0xff000000, 0, startX, rectY, rectWidth, rectHeight, TEXT_STYLE_NORMAL, LEFT_VCENTER);
        tmpX = rectX;
        tmpX += 4;

        tmpY = rectY;
        tmpY += 2;

        tmpWidth = rectWidth;
        tmpWidth -= 8;

        tmpHeight = rectHeight;
        tmpHeight -= 4;
        if (selected) {
            tmpX = rectX;
            tmpX += 1;
            tmpY = rectY;
            tmpY -= 1;
            tmpWidth = rectWidth;
            tmpWidth -= 2;
            tmpHeight = rectHeight;
            tmpHeight += 2;
            g.DrawRectRim(tmpX, tmpY, tmpWidth, tmpHeight, 1, 0xffffffff);
            g.DrawRectRim(tmpX, tmpY, tmpWidth, tmpHeight, 3, 0xff13c2f4);
        } else {
            g.DrawRectRim(tmpX, tmpY, tmpWidth, tmpHeight, 1, 0xff13c2f4);
        }
    }

    public HLString GetName() {
        return null;
    }

}
